package com.laikan.reader.core.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.laikan.reader.core.LaikanBaseAdapter;
import com.laikan.reader.R;
import com.laikan.reader.core.bean.More;

import java.util.ArrayList;
import java.util.List;

public class CateRankAdapter extends LaikanBaseAdapter<More> {

    public CateRankAdapter(Context context, List<More> moreList) {
        super(context, (ArrayList<More>)moreList);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(mContext, R.layout.lk_rank_cate_item, null);
            convertView.setTag(holder);
            holder.book_img = (SimpleDraweeView)convertView.findViewById(R.id.book_img);
            holder.book_name = (TextView)convertView.findViewById(R.id.book_name);
            holder.book_writer = (TextView)convertView.findViewById(R.id.book_writer);
            holder.book_des = (TextView)convertView.findViewById(R.id.book_des);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder)convertView.getTag();
        }

        holder.book_img.setImageURI(Uri.parse(datas.get(position).getIconDefault()));
        holder.book_name.setText(datas.get(position).getBookName());
        holder.book_writer.setText("作者： " + datas.get(position).getAuthName());
        holder.book_des.setText(datas.get(position).getIntroduce());
        return convertView;
    }

    private class ViewHolder {

        public SimpleDraweeView book_img;
        public TextView book_name, book_writer, book_des;
    }

}
